package me.xplabs.view 
{
	import flash.display.Sprite;
	import flash.utils.getQualifiedClassName;
	import me.xplabs.Globals;
	import me.xplabs.interfaces.IBasePanel;
	import me.xplabs.msg.NotificationName;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;
	
	/**
	 * http://www.xplabs.me/
	 * @author xiaohan
	 */
	public class GameMenuMediator extends Mediator implements IBasePanel
	{
		public static var NAME:String;
		private var _container:Sprite;
		private var _isInit:Boolean;
		
		private var _gameMenuView:GameMenuView;
		
		public function GameMenuMediator(viewComponent:Object=null) 
		{
			NAME = getQualifiedClassName(this);
			super(NAME, viewComponent);
		}
		
		private function init():void
		{
			if (_isInit) return;
			_isInit = true;
			_container = new Sprite();
			
			_gameMenuView = new GameMenuView(_container);
			_gameMenuView.show();
			_gameMenuView.setXY(Globals.centerW - _gameMenuView.width * .5, Globals.centerH - _gameMenuView.height * .5);
			
		}
		public function show():void 
		{
			init();
			if (!_container.parent) viewComponent.addChild(_container);
		}
		
		public function hide():void 
		{
			if (_container.parent) _container.parent.removeChild(_container);
		}
		
		override public function handleNotification(notification:INotification):void 
		{
			switch(notification.getName())
			{
				case NotificationName.SHOW_GAME_MENU:
					show();
					break;
				case NotificationName.HIDE_GAME_MENU:
					hide();
					break;
			}
		}
		override public function listNotificationInterests():Array 
		{
			return [NotificationName.SHOW_GAME_MENU, NotificationName.HIDE_GAME_MENU];
		}
		public function dispose():void 
		{
			
		}
		
	}

}